<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
  <style>
    .box{
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      width: 500px;
      height: 500px;
      background-color: red;
    }

    .mask{
      position: absolute;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;

      background-color: #000;
      opacity: 0.5;
      color: #fff;

      display: flex;
      justify-content: center;
      align-items: center;
    }

    #root{
      position: absolute;
      width: 300px;
      height: 300px;
      background-color: skyblue;
    }
  </style>
</head>
<body>
  <div id="app"></div>
  <div id="root"></div>
  <script src="js/vue.js"></script>
  <script>
    const app = Vue.createApp({
      data() {
        return {
          msg: '撩课学院',
          isShow: false
        }
      },
      methods:{
        btnClick(){
          this.isShow = !this.isShow
        }
      },
      template: `
        <div class="box">
           <button @click="btnClick">蒙版</button>
           <!--<div class="mask" v-show="isShow">{{msg}}</div>-->

           <!--
           <teleport to="body">
             <div class="mask" v-show="isShow">{{msg}}</div>
           </teleport>
           -->

           <teleport to="#root">
             <div class="mask" v-show="isShow">{{msg}}</div>
           </teleport>
        </div>
      `
    }).mount('#app');
  </script>
</body>
</html>
